package edu.ptu.communityplatform.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import edu.ptu.communityplatform.common.controller.AjaxResponse;
import edu.ptu.communityplatform.common.controller.BaseController;
import edu.ptu.communityplatform.domain.entity.Area;
import edu.ptu.communityplatform.domain.vos.AreaVos;
import edu.ptu.communityplatform.domain.vos.ProvVos;
import edu.ptu.communityplatform.service.IAreaService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

import static edu.ptu.communityplatform.mapping.AreaMapping.AREA_MAPPING;

/**
 * @BelongsProject: communityPlatform
 * @BelongsPackage: edu.ptu.communityplatform.controller
 * @Author: HYJ
 * @CreateTime: 2025-04-10  00:00
 * @Description: TODO
 * @Version: 1.0
 */
@RestController
@RequestMapping("/area")
public class AreaController extends BaseController {

    @Resource
    private IAreaService areaService;

    /**
     * 获取所有的省和市区信息
     * 省：市：区
     */
    @GetMapping()
    public AjaxResponse getAreaList() {

        List<ProvVos> areaList = areaService.getAreaList();

        if (areaList == null || areaList.isEmpty()) {
            return AjaxResponse.fail("查询失败");
        }
        return AjaxResponse.success(areaList);
    }
}